package hao.bk.royalmap;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class TransportGeneralLayout extends RelativeLayout implements
		OnClickListener {
	
	public PublicTransportLayout transportLayout;
	private RoyalMapActivity main;
	private LinearLayout taxiGroup;
	private LinearLayout taxiMaiLinh;
	private LinearLayout taxiABC;
	private LinearLayout taxiTheKyMoi;
	private Button btnClose;
	
	public TransportGeneralLayout(Context context) {
		super(context);
		main = (RoyalMapActivity)context;
		inflate(main, R.layout.public_transport, this);
		// Tham chiếu đến các thành phần trong Transport layout
		taxiGroup = (LinearLayout)findViewById(R.id.call_taxi_group);
		taxiGroup.setOnClickListener(this);
		taxiMaiLinh = (LinearLayout)findViewById(R.id.call_taxi_mailinh);
		taxiMaiLinh.setOnClickListener(this);
		taxiABC = (LinearLayout)findViewById(R.id.call_taxi_abc);
		taxiABC.setOnClickListener(this);
		taxiTheKyMoi = (LinearLayout)findViewById(R.id.call_taxi_thekymoi);
		taxiTheKyMoi.setOnClickListener(this);
		btnClose = (Button)findViewById(R.id.close_info_transport);
		btnClose.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.call_taxi_group:
			String group = main.getResources().getString(R.string.phone_group);
			callTaxi(group);
			break;
		case R.id.call_taxi_mailinh:
			String mailinh = main.getResources().getString(R.string.phone_mailinh);
			callTaxi(mailinh);
			break;
		case R.id.call_taxi_abc:	
			String abc = main.getResources().getString(R.string.phone_abc);
			callTaxi(abc);
			break;
		case R.id.call_taxi_thekymoi:
			String thekymoi = main.getResources().getString(R.string.phone_thekymoi);
			callTaxi(thekymoi);
			break;
		case R.id.close_info_transport:
			main.flagViewMap = true;
			main.gonePublicTransport();
		default:
			break;
		}
	}
	/** gọi điện đến hãng taxi*/
	public void callTaxi(String numberPhone) {
		String uri = "tel:" + numberPhone;
		Intent intent = new Intent(Intent.ACTION_DIAL);
		intent.setData(Uri.parse(uri));
		main.startActivity(intent);
	}

}
